<?php
class SabbathschoolbooketsController extends AppController {

    public $helpers = array('Html', 'Form');
    public $components = array('Session');

    public function index() {
        $pageTitle ="Worldwide Seventhday-Adventisth Church - Kwabrafoso: Sabbath School Study Guide";
        $in_record_data = $this->Sabbathschoolbooket->find('all');
        $this->set(compact('in_record_data','pageTitle'));
    }

    
    public function add(){
    $pageTitle ="Worldwide Seventh-day Adventist Church - Kwabrafoso: Enter Sabbath School Study Guide";
     if($_POST){
       // pr($_POST);
        $data[' Sabbathschoolbooket'] = array(
            'booktype' => $_POST['booktype']
        );

        if(!$this->Sabbathschoolbooket->save($data)){
            $this->Session->setFlash('Error Saving Sabbath School Study Guide');
        }else{
             $this->Session->setFlash('Sabbath School Study Guide Saved');
            $this->redirect('index');
        }
    }

    $this->set(compact('pageTitle','errorMsg'));
}
    
    // A functin to delete Sabbathschoolbooket
    public function delete($id = null)
    {
       if (!$id) 
       {
        $this->Session->setFlash('Invalid id for Sabbath School Study Guide');
        $this->redirect(array('action' => 'index'));
    }
    if ($this->Sabbathschoolbooket->delete($id)) 
    {
        $this->Session->setFlash('Sabbath School Study Guide Deleted Please');
    } else 
    {
        $this->Session->setFlash(__('Sabbath School Study Guide Not Deleted', true));
    }
    $this->redirect(array('action' => 'index'));
}

    // A functin to edit Sabbath School Study Guide
    function edit($id = null){
    $record_id = $id;
    $conditions = array('Sabbathschoolbooket.id' => $record_id);
    $record = $this->Sabbathschoolbooket->find('first', array('conditions' => $conditions, 'recursive' => 1));
   // pr($record);
            
     $pageTitle ="Worldwide Seventh-day Adventist Church - Kwabrafoso: Edit Sabbath School Study Guide";
     if($_POST){
        //pr($_POST);
        $data[' Sabbathschoolbooket'] = array(
            'booktype' => $_POST['booktype']
        );

        if(!$this->Sabbathschoolbooket->save($data)){
            $this->Session->setFlash('Error Saving Data');
        }else{
             $this->Session->setFlash('Data Saved');
            $this->redirect('index');
        }
    }

    $this->set(compact('pageTitle','record'));
}

     // A functin to view Records
    public function view($id) {
    if (!$id) {
        throw new NotFoundException(__('Invalid Record'));
    }

    $sabbathschoolbooket = $this->Sabbathschoolbooket->findById($id);
    if (!$sabbathschoolbooket) {
        throw new NotFoundException(__('Invalid Record'));
    }
    $this->set('Sabbathschoolbooket', $sabbathschoolbooket);
}

function report($id = null){
    $record_id = $id;
    $conditions = array('Sabbathschoolbooket.id' => $record_id);
    $record = $this->Sabbathschoolbooket->find('first', array('conditions' => $conditions, 'recursive' => 1));
//    pr($record);

}

}
?>
